use thiserror::Error;

/// The unified error type for the expansion system.
#[derive(Debug, Error)]
pub enum ExpansionError {
    /// Error during manifest deserialization.
    #[error("Manifest parsing error: {0}")]
    ManifestParse(#[from] serde_json::Error),

    /// Error related to file I/O.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    /// A specified plugin was not found in the static registry.
    #[error("Plugin '{0}' is not registered.")]
    PluginNotRegistered(String),

    /// A cyclic dependency was detected among plugins.
    #[error("Found cyclic dependency: {0}")]
    CyclicDependency(String),

    /// A general validation error found in a manifest.
    #[error("Manifest validation failed: {0}")]
    ManifestValidation(String),

    /// A general-purpose error with a custom message.
    #[error("{0}")]
    Msg(String),
}

/// A specialized `Result` type for the expansion system.
pub type Result<T> = std::result::Result<T, ExpansionError>;
